<?php
/**
 * Created by PhpStorm.
 * User: caoguangyang
 * Date: 2022-02-02
 * Time: 19:03
 */

namespace App\Services;


use App\CodeResponse;
use App\Exceptions\BusinessException;

class BaseServices
{
    protected static $instance;

    /**
     * @return mixed
     */
    public static function getInstance() {
        if (static::$instance instanceof static) {
            return static::$instance;
        }
        static::$instance = new static();
        return static::$instance;
    }

    public function __clone()
    {
        // TODO: Implement __clone() method.
    }

    public function __construct()
    {
    }

    public function throwBusinessException(array $codeResponse) {
        throw new BusinessException($codeResponse);
    }

    /**
     * @throws BusinessException
     */
    public function throwBadArgumentValue()
    {
        $this->throwBusinessException(CodeResponse::PARAM_VALUE_ILLEGAL);
    }

    /**
     * @throws BusinessException
     */
    public function throwUpdateFail()
    {
        $this->throwBusinessException(CodeResponse::UPDATED_FAIL);
    }
}